<template>
  <div style="text-size: 8px">
    <div class="top">
      <el-row>
        <el-col :span="24"
          ><h3><i class="el-icon-search"></i> 筛选搜索</h3></el-col
        >
      </el-row>
      <el-row>
        <el-col :span="6"><br></el-col>
        <el-col :span="6">
          <el-input
            placeholder="请输入内容"
            prefix-icon="el-icon-search"
            v-model="lookup"
          >
          </el-input
        ></el-col>
        <el-col :span="9">
          <el-button type="primary" @click="mianshilookup" ><i class="el-icon-search"></i>搜索</el-button>
        </el-col>
        <el-col :span="3">
          <el-button  type="primary" @click="tianj"
            >添加<i class="el-icon-upload el-icon--right"></i
          ></el-button>
        </el-col>
      </el-row>
    </div>
    <el-card class="operate-container" shadow="never">
      <i class="el-icon-tickets"></i>
      <span>数据列表</span>
      <el-button
        class="btn-add"
        @click="Batchdelete()"
        size="mini">
        批量删除
      </el-button>

    </el-card>
    <div class="body">
    <el-table :data="list" style="width: 100%"  @selection-change="handleSelectionChange">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>

      <el-table-column label="ID" width="80">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.infoId }}</span>
        </template>
      </el-table-column>
      <el-table-column label="公司名称" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.name }}</span>
        </template>
      </el-table-column>
      <el-table-column label="公司位置 " width="200">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.address }}</span>
        </template>
      </el-table-column>
      <el-table-column label="公司类型" width="180">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.postType }}</span>
        </template>
      </el-table-column>
      <el-table-column label="面试岗位" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.postName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="面试时间" width="300">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.interviewTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="岗位设定薪资" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.postSalary }}</span>
        </template>
      </el-table-column>
      <el-table-column label="面试结果" width="150">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.result }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否一面" width="150">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.isFrist }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否进入下轮" width="150">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.isNext }}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否录用" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.isLy }}</span>
        </template>
      </el-table-column>

      <el-table-column  fixed="right" label="操作" width="200">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)"
            ><i class="el-icon-edit"></i
          ></el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.row.infoId)"
            ><i class="el-icon-delete"></i
          ></el-button>
          <el-button
            size="mini"
            type="danger"
            @click="look(scope.row)"
            >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination
        background
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        layout="total, sizes,prev, pager, next,jumper"
        :page-size="listQuery.pageSize"
        :page-sizes="[2, 4, 8]"
        :current-page.sync="listQuery.pageNum"
        :total="total"
      >
      </el-pagination>
    </div>
    
    </div>
  </div>
</template>
 
<script>
import { mianshigetlist, mianshidelet,mianshilookup,mianshibatchdelete } from "@/api/mianshi";
export default {
  data() {
    return {
      operateType: null,
      listQuery: {
        keyword: null,
        nameCn: null,
        pageNum: 1,
        pageSize: 4,
      },
      list: null ,
      total: null,
      listLoading: true,
      multipleSelection: [],
      lookup:null,
      multipleSelection:[],
      cklook:false
    };
  },
  created() {
    this.chax();
  },
  methods: {
    chax() {//查询分页
      this.listLoading = true;
      console.log("------------------------------1");
      mianshigetlist(this.listQuery).then((response) => {
        this.listLoading = false;
        this.list = response.data.records;
        this.total = response.data.total;
        this.totalPage = response.data.pages;
        this.pageSize = response.data.size;
        console.log(response.data);
      })
    },
    handleSizeChange(val) {
      this.listQuery.pageNum = 1;
      this.listQuery.pageSize = val;
      this.chax();
    },
    handleCurrentChange(val) {
      this.listQuery.pageNum = val;
      this.chax();
    },
    handleEdit(row) {
      this.$router.push({ path: "/from/tianjia", query: { row } });
    },

    handleDelete(id) {//单个删除
      this.$confirm("确定删除他吗?", "提示", {
        confirmButtonText: "删除",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        mianshidelet(id).then((response) => {
          this.$message({
            message: "已经删除成功了哟！",
            type: "success",
            duration: 1000,
          });
          this.chax();
        });
      });
    },

   mianshilookup() {//模糊查询
       mianshilookup(this.lookup).then((response) => {
        this.listLoading = false;
        this.list = response.data;
        this.total = response.data.total;
        this.totalPage = response.data.pages;
        this.pageSize = response.data.size;
      });
    },
      handleSelectionChange(val) {//批量删除获取id
        this.multipleSelection = val;
      },
      Batchdelete(){//批量删除
          var arr=[];
          for(var a=0;a<this.multipleSelection.length;a++){
            arr.push(this.multipleSelection[a].infoId)
          }
          mianshibatchdelete(arr).then((response) => {
            console.log(response)
            this.chax()
          })         
      },
      look(row){
         const look = this.cklook;
        this.$router.push({path: "/from/tianjia", query: {row, look }})
      },

    tianj() {//添加
      this.$router.push({ path: "/from/tianjia" });
    },
  },
};
</script>

<style>
.tj {
  position: relative;
  left: 1350px;
}
.top {
  margin: 10px 30px;
  padding: 10px;
  border: 1px solid rgb(225, 215, 215);
}
.body{
   margin: 10px 30px;
    border: 1px solid rgb(225, 215, 215);
}
.operate-container{
  margin: 10px 30px;
}
</style>